package com.zyc.demo.rabbitmq.sender;

import com.zyc.demo.rabbitmq.config.ConstantVar;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TopicExchangeSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(String msg,String routingKey){
        String topicExchangeName = ConstantVar.topicExchangeName;
        amqpTemplate.convertAndSend(topicExchangeName,routingKey,msg);
        System.out.println("消息发送成功，消息为："+msg);
    }
}
